home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / HENSA / MATHS / PLPLOT / PLPLOT.ZIP / sys / amiga / old / hpplot.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-03-16  |  4.3 KB  |  186 lines

  1. /* $Id: hpplot.c,v 1.1 1993/03/15 21:30:51 mjl Exp $
  2.    $Log: hpplot.c,v $
  3.  * Revision 1.1  1993/03/15  21:30:51  mjl
  4.  * Files shuffled around in the Amiga driver reorganization.
  5.  *
  6.  * Revision 1.2  1992/10/12  17:11:21  mjl
  7.  * Amiga-specific mods, including ANSI-fication.
  8.  *
  9.  * Revision 1.1  1992/05/20  21:35:24  furnish
  10.  * Initial checkin of the whole PLPLOT project.
  11.  *
  12. */
  13.  
  14.  /* This file contains drivers for the HP7475A plotter */
  15.  
  16.  /* Note this file is horribly out of date and will no longer work with the */
  17.  /* package.  I only keep it because it is a bit different from the other two */
  18.  /* hp drivers in the plplot/drivers directory (why?).  If I get around to */
  19.  /* verifying that those work fine with the Amiga PLT: device, this file will */
  20.  /* get tossed. */
  21.  
  22. #include "plplot.h"
  23. #include <stdio.h>
  24. #include <string.h>
  25.  
  26. #define PLTX       10299
  27. #define PLTY        7649
  28.  
  29. static FILE *OutDev;
  30. static PLINT orient;
  31. static PLINT select=0;
  32. static char FileName[80];
  33.  
  34. void hp7475setup(xdpi, ydpi, xwid, ywid)
  35. PLINT xwid, ywid;
  36. PLFLT xdpi, ydpi;
  37. {
  38. }
  39.  
  40. void hp7475select(ori, name)
  41. PLINT ori;
  42. char *name;
  43. {
  44.    orient = ori;
  45.    strncpy(FileName,name,sizeof(FileName)-1);
  46.    FileName[sizeof(FileName)-1] = '\0';
  47.    select = 1;
  48. }
  49.  
  50. /* Set up device specific stuff and initialize the device */
  51. /* If orient is 0 set up for landscape, otherwise portrait. */
  52. void hp7475init()
  53. {
  54.    char line[80];
  55.  
  56.    if(!select) {
  57.       printf("Landscape or portrait orientation? (0 or 1) ");
  58.       fgets(line,sizeof(line),stdin);
  59.       if(sscanf(line,"%d",&orient) != 1)
  60.          orient = 0;
  61.    }
  62.  
  63.    /* setpxl() sets the dots/mm in the x and y directions */
  64.    setpxl((PLFLT)40.,(PLFLT)40.);         /* 40 dots/mm or 1016 dots/inch */
  65.  
  66.    /* setphy() sets the device coordinates. These are integer */
  67.    /* values. Set up for landscape orientation (long axis of page in the */
  68.    /* x direction). Origin is in the lower left hand corner. */
  69.    if(!orient)
  70.       setphy(0,PLTX,0,PLTY);
  71.    else
  72.       setphy(0,PLTY,0,PLTX);
  73.  
  74.    /* Set default pen color using scol(color). */
  75.    /* Any default pen color can be used but a black pen is probably best. */
  76.    scol(1);
  77.  
  78.    /* Set default pen width using swid(width) */
  79.    swid(1);
  80.  
  81.    /* Set device interaction mode using smod(mode). Set mode to 0 for */
  82.    /* a noninteractive device, Unless you are writing your */
  83.    /* own Amiga screen driver mode should be 0. */
  84.    smod(0);
  85.  
  86.    /* Well that's all the information plplot needs. Let's prompt for a */
  87.    /* graphics file name. */
  88.    for(;;) {
  89.       if(!select) {
  90.          printf("Enter graphics file name. ");
  91.          fgets(line,sizeof(line),stdin);
  92.          if(sscanf(line,"%s",FileName)!=1)
  93.             continue;
  94.       }
  95.  
  96.       if (!(OutDev = fopen(FileName,"w"))) {
  97.          fprintf(stderr,"Can't open %s.\n",FileName);
  98.          select = 0;
  99.       }
  100.       else
  101.          break;
  102.    }
  103.    select = 0;
  104.    fprintf(OutDev,"IN; ");
  105. }
  106.  
  107. /* Sets to text mode */
  108. void hp7475text()
  109. {
  110.    /* None of the built in fonts are supported yet. */
  111. }
  112.  
  113. /* Sets to graphics mode */
  114. void hp7475graph()
  115. {
  116.    /* We're always in graphics mode with this device. */
  117. }
  118.  
  119. /* Clears the page */
  120. void hp7475clear()
  121. {
  122.    /* On the HP plotter eject the page. */
  123.    fprintf(OutDev,"PG; ");
  124. }
  125.  
  126. static PLINT xlast, ylast;
  127.  
  128. void hp7475page()
  129. {
  130.    xlast = -100000; ylast = -100000;
  131. }
  132.  
  133. void hp7475width(width)
  134. PLINT width;
  135. {
  136. }
  137.  
  138. /* Change the pen color */
  139. void hp7475color(color)
  140. PLINT color;
  141. {
  142.    if(color<1 || color>8)
  143.       fprintf(stderr,"Invalid pen selection.\n");
  144.    else
  145.       fprintf(OutDev,"SP %d;",color);
  146. }
  147.  
  148.  
  149. /* Draws a line from (x1,y1) to (x2,y2) */
  150. void hp7475line(x1,y1,x2,y2)
  151. PLINT x1,y1,x2,y2;
  152. {
  153.  
  154.    /* If starting point of this line is the same as the ending point of */
  155.    /* the previous line then don't raise the pen. (This really speeds up */
  156.    /* plotting and reduces the size of the file. */
  157.    if(!orient) {
  158.       if(x1 == xlast && y1 == ylast)
  159.          fprintf(OutDev," %d %d",x2,y2);
  160.       else
  161.          fprintf(OutDev,"\nPU %d %d PD %d %d",x1,y1,x2,y2);
  162.    }
  163.    else {
  164.       if(x1 == xlast && y1 == ylast)
  165.          fprintf(OutDev," %d %d",PLTX-y2,x2);
  166.       else
  167.          fprintf(OutDev,"\nPU %d %d PD %d %d",PLTX-y1,x1,PLTX-y2,x2);
  168.    }
  169.  
  170.    xlast = x2;
  171.    ylast = y2;
  172. }
  173.  
  174. /* Cleanup and close file. */
  175. void hp7475tidy()
  176. {
  177.    fprintf(OutDev,"\nSP0");
  178.    fclose(OutDev);
  179. }
  180.  
  181. void hp7475esc(op, ptr)
  182. int op;
  183. char *ptr;
  184. {
  185. }
  186.